package createModel.prototypeModel;
import java.util.Calendar;
import java.util.Date;

public class ClientPrototypeTest {
    public static void main(String[] args) throws CloneNotSupportedException {
        User user = new User();
        String userName = "张三";
        user.setUserName(userName);
        user.setPassword("123124213");
        Date birthday = new Date();
        user.setBirthday(birthday);


        System.out.println(user);
        User userClone = (User) user.clone();
        System.out.println(userClone);

        birthday.setTime(123123213L);
        System.out.println(user);
        System.out.println(userClone);

        User deepCopyUser = user.deepCopy();
        System.out.println(deepCopyUser);

        user.setBirthday(Calendar.getInstance().getTime());
        System.out.println(user);
        System.out.println(deepCopyUser);
        //User{userName='张三', password='123124213', birthday=Thu Jan 11 15:21:14 CST 2024}
        //User{userName='张三', password='123124213', birthday=Thu Jan 11 15:21:14 CST 2024}
        //User{userName='张三', password='123124213', birthday=Fri Jan 02 18:12:03 CST 1970}
        //User{userName='张三', password='123124213', birthday=Fri Jan 02 18:12:03 CST 1970}
    }
}
